﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Model;
using BLL;
namespace Badminton
{
    public partial class BookingForm : Form
    {
        //public static string Court_status;
        public BookingForm()
        {
            InitializeComponent();
            this.lblCourtID.Text = BookStatusForm.SeletedCourt.ToString();
        }
        private void BookingForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //Court_status = BLL.BllOperater.GetChangeCourtStatus(1);
            //MessageBox.Show("1号场地的状态：  " + Court_status, "1");
            if(!this.IsDisposed)
            { 
                BookStatusForm bsf = new BookStatusForm();
                bsf.Show();
            }


        }

        private void btnOutSumbit_Click(object sender, EventArgs e)
        {
            this.Close();
             
        }
       
        private void btnSumbit_Click(object sender, EventArgs e)
        {
           if (this.Court_light.SelectedItem== null)
            {
                MessageBox.Show(">>>>>>>>未选择场是否开灯>>>>>>>>…………", "场地号  或 开灯状态 为空", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int Court_ID =BookStatusForm.SeletedCourt;
                decimal price = BLL.BllOperater.GetCourtPrice(Court_ID);
                Model.Booking b = new Booking(this.txtBUser_name.Text.Trim(), Court_ID, price,
                txtBUser_blance.Text.Trim(), txtBUser_tel.Text.Trim(), this.Court_light.SelectedItem.ToString(),
                 FormLogin.CurrentOperater);


                DialogResult dres = MessageBox.Show(
                    "你的姓名：  " + this.txtBUser_name.Text.Trim() + "\n" +
                    "你选择的场地号是： " + Court_ID + "\n" +
                    "场地价格是： " + price.ToString() + "\n" +
                    "你的押金为： " + txtBUser_blance.Text.Trim() + "\n" +
                    "你的联系方式是： " + txtBUser_tel.Text.Trim() + "\n" +
                    "灯光开关状态为： " + this.Court_light.SelectedItem.ToString() + "\n" +
                    
                    "操作员是： " + FormLogin.CurrentOperater + "\n",
                    "尊敬的顾客:  你的订场信息如下…………", MessageBoxButtons.YesNo,
                MessageBoxIcon.Information);

                if (dres == DialogResult.Yes)
                {
                    if (BLL.BllOperater.BookingInsert(b))
                    {
                        MessageBox.Show("恭喜你订场成功了…………~O(∩_∩)O哈哈~…………", "订场详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("很遗憾,订场失败……%>_<%…………", "订场详情", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("请填写正确的信息", "<<<<<<<<<返回…………", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void btnAgin_Click(object sender, EventArgs e)
        {
            DialogResult dres = MessageBox.Show("尊敬的顾客:  你好，你还要继续订场吗？", "继续订场提示", MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Information);
            if (dres == DialogResult.Yes)
            {
                this.Show();
            }
            else
            {
                this.Close();
            }

        }

    }
}